<template>
	<view class="page">
		<view class="name2">
			<text class="name2_1">{{info.sname}} {{info.dir}}</text>
		</view>
		<uni-forms :modelValue="formData" label-width="160rpx">
			<uni-forms-item label="故障现象" name="xianxiang">
				<uni-easyinput type="text" v-model="formData.xianxiang" placeholder="请输入故障现象" />
			</uni-forms-item>
		</uni-forms>
		<u-button class="btn" @click="submit" type="primary" text="提交" />
	</view>
</template>

<script>
	import {
		addAppTask
	} from '@/api/common.js';
	export default {
		data() {
			return {
				info: '',
				formData: {},
				order:{}
			}
		},
		onLoad: function(option) {
			console.log("onLoad:" + option.info)
			uni.getStorage({
				key: 'order',
				success: (e) => {
					this.order = e.data
				}
			})
			this.info = JSON.parse(option.info)
		},
		methods: {
			submit() {
				addAppTask({
					xianxiang: this.formData.xianxiang,
					siteid: this.info.id,
					laiyuan: '售后',
					projectid:this.order.id,
				}).then(res => {
					console.log('查詢結果：' + JSON.stringify(res));
					uni.showToast({
						title: "修改成功",
						icon: 'none'
					});
					setTimeout(() => {
						uni.navigateBack();
					}, 500)
				}).catch(err => {
					console.log(err);
					uni.showToast({
						title: err,
						icon: 'none'
					});
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		margin-top: 32rpx;
		width: 710rpx;
		margin-left: 16rpx;
		margin-right: 16rpx;
	}

	.name2 {
		height: 120rpx;
		width: 84vw;
		@include flex();
		margin-bottom: 4vh;

		.name2_1 {
			color: $font-color;
			font-size: 40rpx;
			width: 100vw;
			text-align: center;
		}
	}
</style>